package com.buba.controller;

import cn.hutool.json.JSONObject;
import com.buba.service.FollowUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.CommonResult;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @descriptions: 关注用户
 * @author: ZQ
 * @date: 2023/3/8 14:26
 */
@RestController
@RequestMapping("/followUser")
public class FollowUserController {
    @Resource
    FollowUserService followUserService;

    /**
     * @descriptions 获取关注信息
     * @author ZQ
     * @date 2023/3/8 14:56
     * @param userId
     * @return result.CommonResult
     */
    @GetMapping("getFollowUserListById")
    public CommonResult getFollowUserListById(Integer userId){
        // userId 不能为空 不能为0
        if (userId != null && userId != 0) {
            // 根据userId 查询关注信息
            List<Map> followUserList = followUserService.getFollowUserListById(userId);
            if (followUserList != null) {
                // friendList不为空返回数据
                return CommonResult.ok(followUserList);
            }else {
                // friendList为空
                return CommonResult.fail("没有人关注你");
            }
        }else {
            // 判断条件为false返回结果
            return CommonResult.fail("id为空");
        }
    }
}
